package com.example.demo;

public class ThreadPriority {
    public static void main(String[] args) {
        System.out.println(Thread.currentThread().getName()+"-----"+Thread.currentThread().getPriority());
        MyPriority myPriority = new MyPriority();
        Thread thread1 = new Thread(myPriority);
        Thread thread2= new Thread(myPriority);
        Thread thread3 = new Thread(myPriority);
        Thread thread4 = new Thread(myPriority);
        Thread thread5 = new Thread(myPriority);
        Thread thread6 = new Thread(myPriority);
        thread1.start();
        thread2.setPriority(2);
        thread2.start();
        thread3.setPriority(Thread.MAX_PRIORITY);
        thread3.start();
        thread4.setPriority(4);
        thread4.start();
        thread5.setPriority(Thread.MIN_PRIORITY);
        thread5.start();
        thread6.setPriority(7);
        thread6.start();
    }
}
class MyPriority implements Runnable{

    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"-----"+Thread.currentThread().getPriority());
    }
}
